package com.vote.business.service.impl;

import java.util.List;

import com.vote.business.domain.vo.VoteInfoVO;
import com.vote.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.vote.business.mapper.VoteInfoMapper;
import com.vote.business.domain.VoteInfo;
import com.vote.business.service.IVoteInfoService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 投票信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-07-14
 */
@Service
public class VoteInfoServiceImpl implements IVoteInfoService 
{
    @Autowired
    private VoteInfoMapper voteInfoMapper;

    /**
     * 查询投票信息
     * 
     * @param voteId 投票信息主键
     * @return 投票信息
     */
    @Override
    public VoteInfo selectVoteInfoByVoteId(Long voteId)
    {
        return voteInfoMapper.selectVoteInfoByVoteId(voteId);
    }

    /**
     * 查询投票信息列表
     * 
     * @param voteInfo 投票信息
     * @return 投票信息
     */
    @Override
    public List<VoteInfo> selectVoteInfoList(VoteInfo voteInfo)
    {
        return voteInfoMapper.selectVoteInfoList(voteInfo);
    }

    /**
     * 新增投票信息
     * 
     * @param voteInfo 投票信息
     * @return 结果
     */
    @Override
    public int insertVoteInfo(VoteInfo voteInfo)
    {
        voteInfo.setCreateTime(DateUtils.getNowDate());
        return voteInfoMapper.insertVoteInfo(voteInfo);
    }

    /**
     * 修改投票信息
     * 
     * @param voteInfo 投票信息
     * @return 结果
     */
    @Override
    public int updateVoteInfo(VoteInfo voteInfo)
    {
        return voteInfoMapper.updateVoteInfo(voteInfo);
    }

    /**
     * 批量删除投票信息
     * 
     * @param voteIds 需要删除的投票信息主键
     * @return 结果
     */
    @Override
    public int deleteVoteInfoByVoteIds(Long[] voteIds)
    {
        return voteInfoMapper.deleteVoteInfoByVoteIds(voteIds);
    }

    /**
     * 删除投票信息信息
     * 
     * @param voteId 投票信息主键
     * @return 结果
     */
    @Override
    public int deleteVoteInfoByVoteId(Long voteId)
    {
        return voteInfoMapper.deleteVoteInfoByVoteId(voteId);
    }
    /**
     * 更新投票信息状态
     *
     * @param voteInfo 投票信息
     * @return 结果
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public int updateVoteInfoStatus(VoteInfo voteInfo) {
        return voteInfoMapper.updateVoteInfoStatus(voteInfo);
    }

    @Override
    public List<VoteInfoVO> selectUserVoteList(VoteInfoVO voteInfoVO) {
        return voteInfoMapper.selectUserVoteList(voteInfoVO);
    }
}
